home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: judgemi@ix.netcom.com (Michael Judge)
- Newsgroups: comp.lang.c++
- Subject: Re: Visual C++ OLE/ODBC 16bit GPF
- Date: 15 Feb 1996 21:09:01 GMT
- Organization: TSI
- Message-ID: <4g07dd$o6c@reader2.ix.netcom.com>
- NNTP-Posting-Host: ix-bst-ma1-03.ix.netcom.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-NETCOM-Date: Thu Feb 15 1:09:01 PM PST 1996
- X-Newsreader: WinVN 0.99.7
-
- Well I have called Microsoft and they have confirmed that there is a bug when
- using Visual C++1.5x with OLE and ODBC. I recreated it with the steps st the
- end of this article. The problem was with new ODBC drivers releasing
- OLE2DISP.DLL from memory when a referenced should have still existed from the
- OLE application. The fix is to
- 1) Add before (AfxOleInit()) in InitInstance
- myOle2DispInstance=LoadLibrary("OLE2DISP");
- 2) Add to ExitInstance
- FreeLibrary(myOle2DispInstance);
-
- here is the following steps to recreate the problem.
-
- ----------------------------------------------------
- Re: message num (169116)
-
- This is for OLE/ODBC/Microsoft Visual C++ Gurus.
-
- environment: Windows 3.X, ODBC DLLs ver 2.1
-
- O.k. here is the problem then I will describe how to reproduce it. (takes 5
- minutes to reproduce)
- When executing a SQL statement twice on a microsoft ODBC datasource, I recieve
- a GP fault in COMPOBJ.DLL.
- This ONLY happens when ODBC drivers version 2.1 have been installed. So any
- new machine, or old one with new
- software will reproduce this.
-
- If I replace OLE2DISP.DLL ver 2.1 with OLE2DISP.DLL ver 2.0 this problem
- doesnt occur. (of course there are other side affects
- that make this a poor solution.)
-
- here is the kicker! This only happens when I have a 'WHERE' clause in the
- statement. and ONLY in RELEASE!
-
- how to reproduce.
-
- 1: AppWizard new project.
- a. OLE options. (container)
- b. shut off all check boxes under options. (simplifies things)
- c. database support, include header files only
- d. classes: change your view class to a formview class.
- e. let it create all its files
- 2. AppStudio.
- a. Add a button to your formview
- b. class wizard: add a message map for bn_clicked
- c. choose edit code
- 3. CMyFormView::OnButton1() should look like this (also add derivation of
- CRecordset)
-
- class CMyRecordSet: public CRecordset
- {
- public:
- CMyRecordSet(CDatabase *t_ptr);
- virtual CString GetDefaultSQL(){return CString("");}
- virtual void DoFieldExchange(CFieldExchange* pFX){}
- };
- CMyRecordSet::CMyRecordSet(CDatabase *t_ptr)
- :CRecordset(t_ptr)
- {
- }
-
- void CMyFormView::OnButton1()
- {
- CDatabase t_pdatabase;
- t_pdatabase.Open(NULL);
- CMyRecordSet t_set(&t_pdatabase);
- t_set.Open();
- CString t_sqlstatement("SELECT PHYSICIAN from EPD00045 where
- physician='CHAMBERS'");
- ::SQLExecDirect(t_set.m_hstmt,
- (UCHAR FAR*)t_sqlstatement.GetBuffer(0), SQL_NTS);
- t_set.Close();
- t_pdatabase.Close();
- }
-
- 4. change t_sqlstatement to be whatever makes sense to your database you are
- going after
- 5. build for release and execute.
- 6. click on button
- 7. choose a datasource that uses ODBCJT16.DLL (I have tried foxprow, access
- and paradox datasources)
- note: make sure your SQL makes sense
- 8. let it process call then click on button again.
-
- Thats it.
- Oh yes, after this happens, it wont blow up again until you leave windows and
- return.
- I have a VB test app that works fine with it.
- In debug it works
- replace OLE2DISP.DLL v2.1 with v2.0 it works
- if not an ole container it works
-
- Email as well as post please.
- Email: judgemi@ix.netx.com
- ---------------------------------------------------------------------
-
-